/*
 * LiquidBounce Hacked Client
 * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
 * https://github.com/CCBlueX/LiquidBounce/
 */
package net.ccbluex.liquidbounce.features.module.modules.exploit

import net.ccbluex.liquidbounce.api.MinecraftVersion
import net.ccbluex.liquidbounce.api.minecraft.network.play.client.ICPacketUseEntity
import net.ccbluex.liquidbounce.event.AttackEvent
import net.ccbluex.liquidbounce.event.EventTarget
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.features.module.ModuleCategory
import net.ccbluex.liquidbounce.features.module.ModuleInfo

@ModuleInfo(name = "VehicleOneHit", description = "Allows you to break vehicles with a single hit.", category = ModuleCategory.EXPLOIT, supportedVersions = [MinecraftVersion.MC_1_8])
class VehicleOneHit : Module() {

    @EventTarget
    fun onAttack(event: AttackEvent) {
        val targetEntity = event.targetEntity

        if (classProvider.isEntityBoat(targetEntity) || classProvider.isEntityMinecart(targetEntity)) {
            for (i in 0..3) {
                mc.netHandler.addToSendQueue(classProvider.createCPacketAnimation())
                mc.netHandler.addToSendQueue(classProvider.createCPacketUseEntity(targetEntity!!,
                        ICPacketUseEntity.WAction.ATTACK))
            }
        }
    }

}
